package com.cloudfun.campusshare.entity;

import com.cloudfun.campusshare.common.constant.MsgStatus;
import com.cloudfun.campusshare.common.constant.MsgType;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;

/**
 * Created by Huqin on 2019/12/28
 */
@Data
@Entity
@NoArgsConstructor
@AllArgsConstructor
@Builder
@Table(name = "message")
public class MessageEntity extends BaseEntity {

    @Id
    @GenericGenerator(name = "id_uuid", strategy = "uuid")
    @GeneratedValue(generator = "id_uuid")
    @Column(name = "id", unique = true, columnDefinition = ("varchar(40) not null comment '主键uuid'"))
    private String id;

    @Column(columnDefinition = ("varchar(32) not null comment '消息类型'"))
    @Enumerated(EnumType.STRING)
    private MsgType type;

    @Column(columnDefinition = ("varchar(40) not null comment '业务id'"))
    private String bizId;

    @Column(columnDefinition = ("varchar(64) not null comment '主题'"))
    private String subject;

    @Column(columnDefinition = ("varchar(40) not null comment '发信人id'"))
    private String sender;

    @Column(columnDefinition = ("varchar(40) not null comment '收信人id'"))
    private String recipient;

    @Column(columnDefinition = ("varchar(1024) not null comment '消息内容'"))
    private String content;

    @Column(columnDefinition = ("varchar(32) not null comment '消息状态'"))
    @Enumerated(EnumType.STRING)
    private MsgStatus status;

    @Column(columnDefinition = ("tinyint(1) not null comment '伪删'"))
    private Boolean enabled;

}
